import 'dart:async';
import 'package:flutter/material.dart';

class ThemeDataBloc {
  StreamController<ThemeData> _streamController;
  Stream<ThemeData> _stream;
  ThemeData _themeData;

  ThemeDataBloc() {
    _streamController = StreamController.broadcast();
    _stream = _streamController.stream;
    _themeData = ThemeData.light();
  }

  Stream<ThemeData> get stream => _stream;

  changeTheme() {
    _themeData =
        _themeData == ThemeData.light() ? ThemeData.dark() : ThemeData.light();
    _streamController.add(_themeData);
  }

  dispose() {
    _streamController.close();
  }
}
